package com.hopu.oa.dao.user;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;

import com.hopu.oa.entity.dto.user.UserInformation;
import com.hopu.oa.entity.user.AoaUser;
import com.hopu.oa.entity.user.AoaUserLoginRecord;
import com.hopu.oa.entity.work.workDept;
import com.hopu.oa.entity.work.worker;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

@Repository
public interface UserDao extends BaseMapper<AoaUser> {

    @Select("select * from aoa_user")
    public List<AoaUser> selectAll();

    /*
      @Description :  根据 userName/Tel   和 password  查询用户
      @Date   :  2021/11/11
      @Param  : [userName, password]
      @return : com.hopu.oa.entity.user.AoaUser
     */
    AoaUser queryUserByNameOrTelAndPassword(@Param("userName") String userName, @Param("password") String password);


    /*
      @Description : 根据id查询用户
      @Date   :  2021/11/13
      @Param  : [id]
      @return : com.hopu.oa.entity.user.AoaUser
     */
    @Override
    AoaUser selectById(Serializable id);


    int user_updateUserByUserId(UserInformation dtoUser);


    /*
    @Description : 根据用户id 查询部门名称 和  职位
    @Date   :  2021/11/13
    @Param  : [userId]
    @return : java.util.Map<java.lang.String,java.lang.String>
    */
    Map<String, String> queryUserDeptAndPositionById(Integer userId);

    List<AoaUser> queryAllByLimit(@Param("aoaUser") AoaUser aoaUser, @Param("index") int index, @Param("size") int size);

    List<AoaUser> selectAllUser(@Param("loginTime") String loginTime, @Param("userId") Integer userId);

    List<AoaUser> deletePosition(Integer positionId);

    @Insert("insert into aoa_user_login_record (browser,ip_addr,login_time,user_id)values (#{browser},#{ipAddr},#{loginTime},#{userId})")
    int insertLoginRecord(AoaUserLoginRecord aoaUserLoginRecord);

    List<AoaUser> selectByRole(@Param("roleId") Integer roleId);

    List<worker> selectAllWoker(Integer page, Integer size, String deptName, String find);

    @Select("select * from workdept")
    List<workDept> selectDept();

    @Select("select * from aoa_user where user_name = #{user_name}")
    AoaUser selectUserByUserName(String userName);

}